﻿using MediatR;
using U.B.DoMain;
using U.B.ErrorCode;
using U.B.ReadApi.Command;
using U.B.Repistory;

namespace U.B.ReadApi.CommandHander
{
    public class GetAppCommandHander : IRequestHandler<GetAppCommand, ApiResult<List<Approval>>>
    {
        public readonly IRepistory<Approval> _approvalRepistory;
        public GetAppCommandHander(IRepistory<Approval> approvalRepistory)
        {
                _approvalRepistory = approvalRepistory;
        }
        public Task<ApiResult<List<Approval>>> Handle(GetAppCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<Approval>> result = new ApiResult<List<Approval>>();
            result.code =Renum.显示成功;
            result.Message = "显示成功";
            var name = _approvalRepistory.GetAll().ToList();
            var a = name.Where(x => x.LAId == request.LAId).ToList();
            result.Data = a.ToList();
            return Task.FromResult(result);
        }
    }
}
